<template>
	<app-layout>
		<view class="container">
			<view class="hvc">
				<view class="linput">
					<input class="leditbox" @blur="blur" type="text" :value="warepwd" placeholder-class="peditext"
						placeholder="请输入进仓码" />
				</view>
				<view class="lbutton" :class="themeObject.back" @click="toware">
					<button type="default" :plain="true" class="lbtn">验证进仓码</button>
				</view>
				<view class="ltips" v-if="mch_id != 0 && status == 3">
					输入密码进入后即可更换后台总经理
				</view>
			</view>
		</view>
	</app-layout>
</template>

<script>
	import {
		mapGetters
	} from 'vuex';

	export default {
		data() {
			return {
				warepwd: '',
				status: 0,
				mch_id: 0,
				id: 0
			}
		},
		onLoad(options) {
			if (options.status) {
				this.status = parseInt(options.status)
			}
			if (options.mch_id) {
				this.mch_id = parseInt(options.mch_id)
			}
			if (options.id) {
				this.id = parseInt(options.id)
			}
		},
		methods: {
			blur(e) {
				this.warepwd = e.target.value
			},
			toware() {
				if (this.warepwd == '') {
					uni.showToast({
						icon: 'none',
						title: '请输入进仓码',
						duration: 2000
					})
					return;
				}
				if (this.warepwd == JSON.parse(this.getSetting.vdian_earnings_ratio).passwd) {
					if (this.$store.state.user.info.vdian_id != null) {
						if (this.$store.state.user.info.vdian_id != '') {
							if (this.status == 1) {
								if (this.mch_id == 0) {
									uni.redirectTo({
										url: '/pages/store/mine/mine'
									})
								} else {
									uni.redirectTo({
										url: '/pages/store/boutique/boutique?id=' + this.id + '&mch_id=' + this
											.mch_id
									})
								}
							} else if (this.status != 3) {
								uni.redirectTo({
									url: '/pages/bepartner/apply/apply'
								})
							} else {
								if (this.mch_id == 0) {
									uni.redirectTo({
										url: '/pages/bepartner/apply/apply'
									})
								} else {
									uni.redirectTo({
										url: '/pages/store/warelist'
									})
								}
							}
						}
					} else {
						uni.redirectTo({
							url: '/pages/store/warelist'
						})
					}
					/* if (this.$store.state.user.info.vdian_id != null && this.status == 1) {
						if (this.mch_id == 0) {
							uni.redirectTo({
								url: '/pages/store/mine/mine'
							})
						} else {
							uni.redirectTo({
								url: '/pages/store/boutique/boutique?id=' + this.id + '&mch_id=' + this.mch_id
							})
						}
					} else if (this.$store.state.user.info.vdian_id != null && this.status != 3) {
						uni.redirectTo({
							url: '/pages/bepartner/apply/apply'
						})
					} else {
						if (this.mch_id == 0) {
							uni.redirectTo({
								url: '/pages/bepartner/apply/apply'
							})
						} else {
							uni.redirectTo({
								url: '/pages/store/warelist'
							})
						}
					} */
				} else {
					uni.showToast({
						icon: 'none',
						title: '进仓码错误'
					})
				}
			}
		},
		computed: {
			...mapGetters('mallConfig', {
				getSetting: 'getSetting',
				getTheme: 'getTheme',
			}),
			themeObject: function() {
				return {
					back: this.getTheme + '-m-back ' + this.getTheme,
					theme: this.getTheme,
					color: this.getTheme + '-m-text ' + this.getTheme,
					sBack: this.getTheme + '-s-back ' + this.getTheme
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		width: 100vw;
		height: 100vh;
		background-color: #FFFFFF;
	}

	.container {
		width: 100vw;
		height: 100vh;
		background-color: #FFFFFF;

		.hvc {
			position: fixed;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
		}

		.logo {
			width: 176rpx;
			// margin: 316rpx auto 56rpx;
			padding: 316rpx 0 56rpx;
			margin: 0 auto;

			.limg {
				width: 176rpx;
				height: 176rpx;
			}
		}

		.linput {
			width: 654rpx;
			/* height: 60rpx;
			line-height: 60rpx; */
			margin: 0 auto 88rpx;
			background: #F5F5F5;
			border-radius: 48rpx;
			color: #342B2A;
			font-size: 28rpx;
			position: relative;

			.leditbox {
				padding: 24rpx;
				border-radius: 48rpx;
				background: #F5F5F5;
				color: #342B2A;
				font-weight: normal;
				width: 100%;
				height: 88rpx;
				box-sizing: border-box;
			}

			.peditext {
				color: #999999;
			}

			.ledit {
				position: absolute;
				top: 20rpx;
				right: 48rpx;
				width: 46rpx;
				height: 48rpx;
			}
		}

		.lbutton {
			width: 654rpx;
			margin: 32rpx auto;
			height: 88rpx;
			border-radius: 56rpx;
			color: #FFFFFF;
			font-size: 24rpx;
			font-weight: bold;

			.lbtn {
				text-align: center;
				width: 654rpx;
				margin: 32rpx auto;
				height: 88rpx;
				line-height: 88rpx;
				font-size: 24rpx;
				font-weight: bold;
				border-radius: 56rpx;
				color: #FFFFFF;
				border: none;
			}
		}

		.ltips {
			width: 654rpx;
			margin: 32rpx auto;
			color: #CDCDCD;
			font-size: 24rpx;
		}
	}
</style>
